package com.cskaoyan.order.service.remote;

import com.cskaoyan.mall.commons.exception.BizException;
import com.cskaoyan.mall.order.constant.OrderRetCode;
import com.cskaoyan.mall.order.dto.PayOrderSuccessRequest;
import com.cskaoyan.mall.order.dto.PayOrderSuccessResponse;
import com.cskaoyan.mall.order.service.PayOrderService;
import com.cskaoyan.order.constant.OrderConstants;
import com.cskaoyan.order.dal.entitys.Order;
import com.cskaoyan.order.dal.entitys.OrderItem;
import com.cskaoyan.order.service.OrderCoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;

import java.util.Date;
import java.util.List;

/**
 * @author Kongwo
 * @description
 * @since 2022/05/19 09:49
 */

@RestController
public class PayOrderServiceImpl implements PayOrderService {

    @Autowired
    OrderCoreService orderCoreService;

    /**
     *  支付成功时，更新订单状态，更新锁定库存，更新订单商品库存状态
     * @param request
     * @return
     */
    @RequestMapping(value = "/rpc/pay/success", method = RequestMethod.PUT)
    @Override
    public PayOrderSuccessResponse payOrderSuccess(PayOrderSuccessRequest request) {

        request.requestCheck();

        // TODO：未测试
        PayOrderSuccessResponse response = orderCoreService.updateOrderAfterPaid(request);
        return response;
    }

}
